package rbtree;

import junit.framework.Assert;
import org.junit.Before;
import org.junit.Test;

/**
 * Projeto : Arvore Preta e Vermelha
 * 
 * Equipe:
 * 			Antonio Eduardo
 * 			Gabriel de Brito
 * 			Gervasio Costa
 * 			Jordan Ferreira
 * 			Wesley Breno
 * 
 */

public class RBNodeTest {

	RBNode<Integer> node1;
	RBNode<Integer> node2;
	RBNode<Integer> node3;
	RBNode<Integer> node4;
	
	@Before
	public void before() {
		node1 = new RBNode<Integer>();
		node2 = new RBNode<Integer>();
		node2.setData(10);
		node3 = new RBNode<Integer>();
		node3.setData(50);
		node4 = new RBNode<Integer>();
		node4.setData(10);
		node4.setColor();
	}
	
	@Test
	public void testToString() {
		Assert.assertEquals(node1.toString(), "NIL");
		Assert.assertEquals(node2.toString(), "(10, B)");
		Assert.assertEquals(node3.toString(), "(50, B)");
		Assert.assertEquals(node4.toString(), "(10, R)");
	}

	@Test
	public void testEqualsObject() {
		Assert.assertFalse( node1.equals(node2) );
		Assert.assertFalse( node2.equals(node3) );
		Assert.assertFalse( node2.equals(node4) );
		node2.setColor();
		Assert.assertTrue( node2.equals(node4) );	
	}
}
